<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>v-model</title>
</head>
<!-- 便捷的设置和获取表单的值，绑定的数据会和表单元素值相关联，绑定数据的值===表单元素的值 -->

<body>
    <div id="app">
        <input type="button" value="点击" @click="alter">
        <input type="text" v-model="introduce" @keyup.enter="getI">
        <!-- 验证是否双向绑定 -->
        <h2>{{introduce}}</h2>
    </div>
</body>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script>
    var app = new Vue({
        el: "#app",
        data: {
            introduce: "黑马程序员"
        },
        //通过一个函数来修改introduce的值
        methods: {
            alter: function() {
                this.introduce = "罗晨"
            },
            getI: function() {
                alert(this.introduce)
            }
        }
    })
</script>

</html>